<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
class Test{
    constructor(){
        this.name = ['wanggang','qili','zhangha'];
        this.age = [23,12,34];
    }

    on(name,age) {
        this.validator(Array.from(arguments));
        console.log('我开始执行注册方法体');
    }

    off(name,age){
        this.validator(arguments);
        console.log('我开始执行注销方法体');
    }

    validator(){
        console.log('我进入校验方法');
        const param= Array.from(arguments)[0];
        if(this.name.includes(param[0]) && this.age.includes(param[1])){
            return true;
        }else {
            throw   "参数错误\nname取值应为:"+this.name+'\nage取值应为:'+this.age;
        }
    }
}

var test = new Test();
test.on('test',15);
</script>
</html>